package cn.mes.module.mes.dal.mysql.basetimeperiod;

import java.util.*;

import cn.mes.framework.common.pojo.PageResult;
import cn.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.mes.framework.mybatis.core.mapper.BaseMapperX;
import cn.mes.module.mes.dal.dataobject.basetimeperiod.BaseTimePeriodDO;
import org.apache.ibatis.annotations.Mapper;
import cn.mes.module.mes.controller.admin.basetimeperiod.vo.*;

/**
 * 时间段配置信息 Mapper
 *
 * @author 游创
 */
@Mapper
public interface BaseTimePeriodMapper extends BaseMapperX<BaseTimePeriodDO> {

    default PageResult<BaseTimePeriodDO> selectPage(BaseTimePeriodPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BaseTimePeriodDO>()
                .eqIfPresent(BaseTimePeriodDO::getShift, reqVO.getShift())
                .eqIfPresent(BaseTimePeriodDO::getLabel, reqVO.getLabel())
                .betweenIfPresent(BaseTimePeriodDO::getTime, reqVO.getTime())
                .betweenIfPresent(BaseTimePeriodDO::getStartTime, reqVO.getStartTime())
                .eqIfPresent(BaseTimePeriodDO::getStartTimeValue, reqVO.getStartTimeValue())
                .betweenIfPresent(BaseTimePeriodDO::getEndTime, reqVO.getEndTime())
                .eqIfPresent(BaseTimePeriodDO::getEndTimeValue, reqVO.getEndTimeValue())
                .eqIfPresent(BaseTimePeriodDO::getOrderNo, reqVO.getOrderNo())
                .betweenIfPresent(BaseTimePeriodDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BaseTimePeriodDO::getShift)
                .orderByAsc(BaseTimePeriodDO::getOrderNo)
                .orderByDesc(BaseTimePeriodDO::getTime)
        );

    }

}